<template>
  <div>
    <el-date-picker v-model="date" type="datetime" placeholder="请选择时间" value-format="x" />
    <div>时间戳：{{ date }}</div>
    <div>日期格式：<el-input v-model="formatText"></el-input></div>
    <div>是否返回星期：<el-switch v-model="config.week" /></div>
    <div>客户端模式：<el-switch v-model="config.client" /></div>
    <br />
    <br />
    <div>输出结果：{{ result }}</div>
  </div>
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue'
import formatTime from '@/utils/formatTime'

const date = ref()
const formatText = ref('Y-M-D h:m:s')
const config = ref({
  week: false,
  client: false
})

const result = computed(() => {
  return date.value ? formatTime(date.value, formatText.value, config.value) : '--'
})
</script>

<style scoped lang="scss"></style>
